package com.handa.webShell.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.handa.webShell.entity.DO.CommonCommandsCategoryDO;
import com.handa.webShell.mapper.CommonCommandsCategoryMapper;
import com.handa.webShell.service.ICommonCommandsCategoryService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author author
 * @since 2025-07-23
 */
@Service
public class CommonCommandsCategoryServiceImpl extends ServiceImpl<CommonCommandsCategoryMapper, CommonCommandsCategoryDO> implements ICommonCommandsCategoryService {

    @Override
    public List<CommonCommandsCategoryDO> getDirectChildrenNodeIds(Long pid) {
        QueryWrapper<CommonCommandsCategoryDO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("pid", pid);
        return list(queryWrapper);
    }

    @Override
    public List<CommonCommandsCategoryDO> getDirectChildrenNodeIdsIncludeSelf(Long pid) {
        List<CommonCommandsCategoryDO> allChildrenNodeIds = getDirectChildrenNodeIds(pid);
        QueryWrapper<CommonCommandsCategoryDO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", pid);
        CommonCommandsCategoryDO one = getOne(queryWrapper);

        allChildrenNodeIds.add(one);

        return allChildrenNodeIds;
    }
}
